package com.wang.tool.idem.core;


import com.wang.tool.lock.core.LockBody;

import java.io.Serializable;

/**
 * 幂等主体
 *
 * @Author wangshaopeng
 * @Date 2022/6/11
 */
public class IdemBody implements Serializable {

    private static final long serialVersionUID = 99952955077743970L;

    public static final String COMMON_NAMESPACE = "common";

    private String namespace;

    /**
     * 幂等id
     */
    private String idemId;

    /**
     * 幂等前需要加锁时
     * 选填
     */
    private LockBody lockBody;

    /**
     * 幂等
     *
     * @param idemId
     * @return
     */
    public static IdemBody build(String namespace, String idemId) {
        IdemBody body = new IdemBody();
        body.setNamespace(namespace);
        body.setIdemId(idemId);
        return body;
    }


    public String getIdemId() {
        return idemId;
    }

    public void setIdemId(String idemId) {
        this.idemId = idemId;
    }

    public LockBody getLockBody() {
        return lockBody;
    }

    public void setLockBody(LockBody lockBody) {
        this.lockBody = lockBody;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

    @Override
    public String toString() {
        return "IdemBody[" +namespace+","+ idemId + "," + lockBody + "]";
    }
}
